<div class="layui-row layui-col-space15">
	<div class="layui-col-md12">
		<div class="layui-card hxr-layui-card">
			<!-- <div class="layui-form hxradmin-card-header">
				<div class="layui-form-item">
					<div class="layui-inline">
						<label class="layui-form-label">代理用户名</label>
						<div class="layui-input-inline">
							<input type="text" name="users" placeholder="请输入" autocomplete="off" class="layui-input">
						</div>
					</div>
					<div class="layui-inline">
						<button class="layui-btn" data-type="reload" id="searchs">搜索</button>
					</div>
				</div>
			</div> -->
			<div class="layui-card-body">
				<table class="layui-hide" id="list-select-table" lay-filter="list-select-table"></table>
	</script>
			</div>
		</div>
	</div>
</div>
<div class="form-btn" style="bottom: -20px;">
	<input type="button" value="确认选择" class="layui-btn selectok">
 </div>
<script>
	//表格数据渲染
	layui.use(['table', 'form'], function() {
		var table = layui.table,
			form = layui.form,
			$ = layui.$;
			layui.admin.initlist(table,'network/allocate_network',350,[
				[{
					type: 'radio'
				},{field:'network_card_id', title: 'ID', width:60}
				,{field:'product_key', title: '产品key', minWidth:100}
				,{field:'device_name_key', title: '产品秘钥', minWidth:200}]
			],'#list-select-table',465,{obj:layui.admin.device,val1:'network_card_id',val2:'network_card_id'})
		//搜索
		$('#searchs').on('click', function() {
			var val1 = $('input[name="users"]').val()

			//执行重载
			table.reload('list-select-table', {
				page: {
					curr: 1 //重新从第 1 页开始
				},
				where: {
					search_text: val1
				}
			});
		});
		$('.selectok').click(function(){
			var checkStatus = table.checkStatus('list-select-table')
			,checkData = checkStatus.data[0];

			if(!checkData){
				layer.msg('请选择代理商');
			}else{
				if(layui.admin.objData.type==3){
					layui.admin.formapi('device/update',{
						device_id:layui.admin.device.device_id,
						network_card_id:checkData.network_card_id
					});
				}else{
					layui.admin.device.agent_id=checkData.agent_id;
					layui.admin.device.agent_name=checkData.agent_name;
					layer.close(layui.admin.pups);
				}
			}
		});
	});
</script>
